﻿#include "ChangeSelection.h"

ChangeSelection::ChangeSelection(JistTableView *view, int index)
    :m_iOldIndex(index)
{
    m_pTableView = view;
    m_iSelectIndex = view->currentIndex().row();

    setText(QCoreApplication::translate("Undo Commands", "Move Cell"));
}

void ChangeSelection::undo()
{
    if(m_pTableView->currentIndex().row() != m_iOldIndex){
        //m_pTableView->m_isUndoAction = true;
        m_pTableView->refineViewNoUndo(m_iOldIndex);
        //m_pTableView->m_isUndoAction = false;
    }
}

void ChangeSelection::redo()
{
    if(m_pTableView->currentIndex().row() != m_iSelectIndex){
        //m_pTableView->m_isUndoAction = true;
        m_pTableView->refineViewNoUndo(m_iSelectIndex);
        //m_pTableView->m_isUndoAction = false;
    }
}
